import 'package:json_annotation/json_annotation.dart';

import '../../../util/DateUtil.dart';
import '../base/Req.dart';
import 'Message.dart';

part 'PullData2.g.dart';

@JsonSerializable()
class SensitiveWordPullReq extends Req {
  int pageSize = 500;
  String? startServerId;
  DateTime? startDate;

  SensitiveWordPullReq({this.pageSize = 500}): super();

  Map<String, dynamic> toJson() => _$SensitiveWordPullReqToJson(this);
}

@JsonSerializable()
class SensitiveWordItem {
  String word;
  String serverId;
  SensitiveWordStatus status;

  SensitiveWordItem({required this.word, required this.serverId, required this.status});

  factory SensitiveWordItem.fromJson(Map<String, dynamic> map) =>_$SensitiveWordItemFromJson(map);

  Map<String, dynamic> toJson() => _$SensitiveWordItemToJson(this);
}

@JsonSerializable()
class SensitiveWordListItem {
  List<SensitiveWordItem> sensitiveWordList;

  SensitiveWordListItem({required this.sensitiveWordList});

  factory SensitiveWordListItem.fromJson(Map<String, dynamic> map) =>_$SensitiveWordListItemFromJson(map);

  Map<String, dynamic> toJson() => _$SensitiveWordListItemToJson(this);
}

class FileItem {
  String fileUrl;
  String md5;
  int size;
  int? time;
  String fileName;
  String originalName;
  int? imageWidth;
  int? imageHeight;

  FileItem({required this.fileUrl, required this.md5, required this.size, this.time, required this.fileName,
    required this.originalName, this.imageWidth, this.imageHeight});

  factory FileItem.fromJson(Map<String, dynamic> map) =>_$FileItemFromJson(map);

  Map<String, dynamic> toJson() => _$FileItemToJson(this);
}

class MessagePullByMessageIdsReq extends Req {
  List<String> serverMessageIdList;

  MessagePullByMessageIdsReq({required this.serverMessageIdList});

  factory MessagePullByMessageIdsReq.fromJson(Map<String, dynamic> map) =>_$MessagePullByMessageIdsReqFromJson(map);

  Map<String, dynamic> toJson() => _$MessagePullByMessageIdsReqToJson(this);
}

class ConfigPullReq extends Req {
  int pageSize = 500;
  DateTime? startDate;
  String? startServerName;

  Map<String, dynamic> toJson() => _$ConfigPullReqToJson(this);
}

class ConfigItem {
  String name;
  String content;
  ConfigStatus status;

  ConfigItem({required this.name, required this.content, required this.status});

  factory ConfigItem.fromJson(Map<String, dynamic> map) =>_$ConfigItemFromJson(map);
}

class ConfigItemList {
  List<ConfigItem> configItems;

  ConfigItemList({required this.configItems});

  factory ConfigItemList.fromJson(Map<String, dynamic> map) =>_$ConfigItemListFromJson(map);
}

class ModulePullReq extends Req {
  int pageSize = 500;
  DateTime? startDate;
  String? startServerName;

  Map<String, dynamic> toJson() => _$ModulePullReqToJson(this);
}

class ModuleItem {
  String name;
  String description;
  int no;
  ModuleStatus status;
  List<ModuleItemInfo>? moduleItemInfoList;

  ModuleItem({required this.name, required this.description, required this.status, required this.no, this.moduleItemInfoList});

  factory ModuleItem.fromJson(Map<String, dynamic> map) =>_$ModuleItemFromJson(map);
}

class ModuleItemInfo {
  String name;
  String description;
  String icon;
  String? url;
  String? params;
  ModuleItemType type;
  int no;
  ModuleItemStatus status;

  ModuleItemInfo({required this.name, required this.description, required this.status, required this.icon, this.url,
    this.params, required this.type, required this.no});

  factory ModuleItemInfo.fromJson(Map<String, dynamic> map) =>_$ModuleItemInfoFromJson(map);
}

class ModuleItemList {
  List<ModuleItem> moduleInfoItems;

  ModuleItemList({required this.moduleInfoItems});

  factory ModuleItemList.fromJson(Map<String, dynamic> map) =>_$ModuleItemListFromJson(map);
}

class CollectPullReq extends Req {
  int pageSize = 500;
  String? startServerId;
  DateTime? startDate;

  Map<String, dynamic> toJson() => _$CollectPullReqToJson(this);
}

class CollectListItem {
  List<CollectInfoItem> collectInfoItems;

  CollectListItem({required this.collectInfoItems});

  factory CollectListItem.fromJson(Map<String, dynamic> map) =>_$CollectListItemFromJson(map);
}

class CollectInfoItem {
  String? serverId;
  String messageId;
  String sessionId;
  MessageType messageType;
  String content;
  String? labelIds;
  CollectStatus status;

  CollectInfoItem({ this.serverId, required this.messageId, required this.sessionId, required this.messageType,
    required this.content, this.labelIds, this.status = CollectStatus.enable,
  });

  factory CollectInfoItem.fromJson(Map<String, dynamic> map) =>_$CollectInfoItemFromJson(map);

  Map<String, dynamic> toJson() => _$CollectInfoItemToJson(this);
}

enum SensitiveWordStatus {
  enable(1, "有效"),
  disable(2, "无效"),
  ;

  final int value;
  final String desc;

  const SensitiveWordStatus(this.value, this.desc);
}

enum ConfigStatus {
  enable(1, "有效"),
  disable(2, "无效"),
  ;

  final int value;
  final String desc;

  const ConfigStatus(this.value, this.desc);
}

enum ModuleStatus {
  enable(1, "有效"),
  disable(2, "无效"),
  ;

  final int value;
  final String desc;

  const ModuleStatus(this.value, this.desc);
}

enum ModuleItemStatus {
  enable(1, "有效"),
  disable(2, "无效"),
  ;

  final int value;
  final String desc;

  const ModuleItemStatus(this.value, this.desc);
}

enum ModuleItemType {
  page(1, "html页面"),
  origin(2, "原生"),
  ;

  final int value;
  final String desc;

  const ModuleItemType(this.value, this.desc);
}

enum CollectStatus {
  enable(1, "有效"),
  disable(2, "无效"),
  ;

  final int value;
  final String desc;

  const CollectStatus(this.value, this.desc);
}